{% extends "main/base.html" %}
{% load i18n static %}
{% block title %}{% trans '添加项目' %}{% endblock %}
{% block content %}
<div class="col-lg-offset-2 col-lg-8">
    <section class="panel">
        <header class="panel-heading">
            {% trans "添加项目" %}
            {% if form.errors %}
            <p>{% trans "提交的数据有误,请认真检查!" %}</p>
            {% endif %}
        </header>
        <div class="panel-body">
            <form method="post" action="{% url 'main:order_add_item' select_order_id %}" class="form-horizontal">{% csrf_token %}
                {{ form.non_field_errors }}
                {% if request.user.is_authenticated %}
                <input type="hidden" name="created_by" id="id_created_by" value="{{ request.user.id }}">
                {% endif %}
                <input type="hidden" name="order" id="id_order" value="{{ select_order_id }}">
                <div class="form-group">
                    <div class="col-lg-2">{{ form.equipment.label_tag }}</div>
                    <div class="col-lg-10">
                        <div class="input-group">
                            <input class="form-control" type="text" id="equipment_search" value="" placeholder="搜索设备" onchange="refreshBtn();">
                            <span class="input-group-btn"><label class="btn btn-primary" id="search_btn" onclick="loadXMLDoc();">搜索</label></span>
                        </div>
                    </div>
                    <div class="col-lg-offset-2 col-lg-10">
                        <select name="equipment" class="selectpicker form-control" data-live-search="true" required id="id_equipment">
                            <option value="" selected>---------</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-2">{{ form.order_index.label_tag }}</div>
                    <div class="col-sm-2">{{ form.order_index }}{{ form.order_index.errors }}</div>
                    <div class="col-sm-2">{{ form.amount.label_tag }}</div>
                    <div class="col-sm-2">{{ form.amount }}{{ form.amount.errors }}</div>
                    <div class="col-sm-2">{{ form.initial_price_each.label_tag }}</div>
                    <div class="col-sm-2">{{ form.initial_price_each }}{{ form.initial_price_each.errors }}</div>
                </div>
                <div class="form-group">
                    <div class="col-sm-2">{{ form.equipment_notes.label_tag }}</div>
                    <div class="col-sm-10">{{ form.equipment_notes }}{{ form.equipment_notes.errors }}</div>
                </div>
                <div class="form-group" align="right">
                    <div class="col-sm-12">
                        <button type="submit" class="btn btn-primary">{% trans "提交" %}</button>
                    </div>
                </div>
            </form>
        </div>
    </section>
</div>
{% endblock %}
{% block this_js %}
<script type="text/javascript" src="{% static 'main/js/load_equipment.js' %}"></script>
<script>
    window.onload = function(){
        document.getElementById("id_order_index").value={{ next_index }};
	}
</script>
{% endblock %}